import urllib.request
import time
def get_price():
    page = urllib.request.urlopen("http://beans.itcarlow.ie/prices-loyalty.html")
    text = page.read().decode("utf8")
    where = text.find(">$")
    start_price = where + 2
    end_price = where + 6
    return float(text[start_price:end_price])  #how about also returning the validity (date and time) of this price?

buy_beans = input("Do you require current price (Y/N): ")
if buy_beans == "Y":
    print(get_price())
else:
    buy_mark = 95.5
    while buy_mark > 4.74:
        time.sleep(900)
        get_price()
        print("Buy")
